<!-- 搜索项目 -->
<template>
	<view class="">
		<view class="" @click="onClick">
			<u--input
				:placeholder="placeholder"
				:placeholderClass="placeholderClass"
				:placeholderStyle="placeholderStyle"
				:inputAlign="inputAlign"
				:fontSize="fontSize"
				:color="color"
				:prefixIcon="prefixIcon"
				:prefixIconStyle="prefixIconStyle"
				:suffixIcon="suffixIcon"
				:suffixIconStyle="suffixIconStyle"
				:currentProjectStatus="currentProjectStatus"
				:border="border"
				:shape="shape"
				:customStyle="customStyle"
				v-model="title"
				:disabled="true"
				:disabledColor="disabledColor"
				
			></u--input>
		</view>
	</view>
</template>

<script>
	import { erpOmcProjectId } from '@/api/index.js'
	
	export default {
		data() {
			return {
				title:'', // 选中的标题名称
				isClick: false,
			}
		},
		model: {
			prop: 'value',
			event: 'change',
		},
		props: {
			queryOmcPrepareProjectList: {
				type: [Boolean],
				required: false,
				default: false
			},
			dataIsolation: {
				type: [String,Number],
				required: false,
				default: ''
			},
			dataType: {
				type: [String,Number],
				required: false,
				default: ''
			},
			changeStatus: {
				type: [String,Number],
				default: ''
			},
			
			// 判断是立项项目 还是项目变更
			projectStatus: {
				type: String,
				default: '',
			},
			isContractManager: {
				type: Boolean,
				default: false
			},
			// 是否是环评项目
			isBidding: {
				type: String,
				default: ''
			},
			// 签订单位
			signUnit: {
				type: String,
				default: ''
			},
			// 费用类型
			costType: {
				type: String,
				default: ''
			},
			// 投标状态
			tenderStatus: {
				type: String,
				default: ''
			},
			
			// 借款所属团队
			teamName2: {
				type: [String,Number],
				default: ''
			},
			// 对象字段
			objectField: {
				type: [String],
				default: 'basicForm.yzdw'
			},
			// 是否禁用
			disabled: {
				type: Boolean,
				default: false
			},
			// 选中的值
			value: {
				type: [String, Number],
				default: '',
			},
			// 输入框为空时的占位符
			placeholder: {
				type: [String, Number],
				default: '请选择',
			},
			// 指定placeholder的样式类，注意页面或组件的style中写了scoped时，需要在类名前写/deep/
			placeholderClass: {
				type: [String],
				default: '',
			},
			// 指定placeholder的样式，字符串/对象形式，如"color: red;"
			placeholderStyle: {
				type: [String, Object],
				default: 'color: #C0C4CC'
			},
			// 输入框内容对齐方式 - left | center | right
			inputAlign: {
				type: [String,],
				default: 'left',
			},
			// 输入框字体的大小
			fontSize: {
				type: [String, Number],
				default: '15px',
			},
			// 输入框字体颜色
			color: {
				type: [String],
				default: '#303133',
			},
			// 输入框前置图标
			prefixIcon: {
				type: [String],
				default: '',
			},
			// 前置图标样式，对象或字符串
			prefixIconStyle: {
				type: [String, Object],
				default: '',
			},
			// 输入框前置图标
			suffixIcon: {
				type: [String],
				default: '',
			},
			// 前置图标样式，对象或字符串
			suffixIconStyle: {
				type: [String, Object],
				default: '',
			},
			// 边框类型，surround-四周边框，bottom-底部边框，none-无边框
			border: {
				type: [String],
				default: 'surround',
			},
			// 输入框形状，circle-圆形，square-方形
			shape: {
				type: [String],
				default: 'square',
			},
			customStyle: {
				type: [Object],
				default: () => {},
			},
			// 老系统数据查询
			isOldSystem: {
				type: [String],
				default: '',
			},
			// 项目档案状态 - 2 为异常终止状态
			currentProjectStatus: {
				type: [String, Number],
				default: ''
			}
		},
		watch: {
			// 监听value是否有值
			value: {
				handler (val, oldVal) {
					if (val) {
						this.getPurchaseDetail()
					} else {
						this.title = ''
					}
					if (oldVal) {
						this.$emit('change',val);
					}
				},
				immediate: true
			},
		},
		computed: {
			// 当是disabled为true改变禁用的颜色
			disabledColor () {
				if (this.disabled) {
					return '#f5f7fa'
				} else {
					return '#FFFFFF'
				}
			}
		},
		methods: {
			// 获取详情
			getPurchaseDetail () {
				erpOmcProjectId({id: this.value}).then(res => {
					if (res.success) {
						this.title = res.result.projectName
						this.$emit('detail', res.result)
						if (this.isClick) {
							this.$emit('input', res.result)
							this.isClick = false
						}
					}
				})
			},
			
			onClick () {
				if (this.disabled) return
				this.isClick = true
				uni.navigateTo({
					url: `/pages/common/selectProject?id=${this.value}&objectField=${this.objectField}&changeStatus=${this.changeStatus}&dataType=${this.dataType}&signUnit=${this.signUnit}&teamName2=${this.teamName2}&isBidding=${this.isBidding}&projectStatus=${this.projectStatus}&tenderStatus=${this.tenderStatus}&dataIsolation=${this.dataIsolation}&costType=${this.costType}&queryOmcPrepareProjectList=${this.queryOmcPrepareProjectList}&isOldSystem=${this.isOldSystem}&currentProjectStatus=${this.currentProjectStatus}`
				})
			}
		},
		mounted() {
			//初始化数据
			// this.queryDictModelByCodes(this.dictName);
		},
	}
</script>

<style lang="scss" scoped>
	
</style>